package com.cc.jdkjucdemo.CompletableFuture;

import java.util.concurrent.*;

public class CompletableFutureDemo01_03 {

    static ThreadPoolExecutor executor = new ThreadPoolExecutor(
            5,
            50,
            10,
            TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(100),
            Executors.defaultThreadFactory(),
            new ThreadPoolExecutor.AbortPolicy());

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        System.out.println("主线程start ......");

        CompletableFuture.supplyAsync(() -> {
            System.out.println("子线程执行了：" + Thread.currentThread().getName());
            return 10;
        }, executor).thenAccept(result -> {
            System.out.println("thenAccept执行了：" + Thread.currentThread().getName());
            System.out.println("result = " + result);
        });

        System.out.println("主线程end ......");
        executor.shutdown();
    }
}